package com.wish.group05.system.api.factory;

import com.wish.group05.common.core.web.domain.AjaxResult;
import com.wish.group05.system.api.RemoteSmsService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 短信服务降级处理
 * 
 * @author wish
 */
@Component
public class RemoteSmsFallbackFactory implements FallbackFactory<RemoteSmsService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);

    @Override
    public RemoteSmsService create(Throwable throwable) {
        log.error("短信服务调用失败:{}", throwable.getMessage());
        return new RemoteSmsService() {
            @Override
            public AjaxResult sendCode(String token, String ip, String telephone) {
                return AjaxResult.error("短信发送失败："+throwable.getMessage());
            }
        };
    }
}
